#!/bin/bash

    source ~/tinyos.sh

    slf=`ps ax | grep keepalive.hw.python | grep -v grep | wc -l`

    # see fi we're already running
    if [ "${slf:=NULL}" != "2" ] ; then
        exit
    fi

    # restart the driver
    appdir="/root/smote/code/smap/trunk/devices/hydrowatch/"
    filename=`date +%Y%m%d_%H%M`
    cd ${appdir}
    while [ 1 ] ;
    do
        ans=`ps ax | grep "python -u HydroWatchSmap.py" | grep -v grep`
        if [ "${ans:=NULL}" != "NULL" ] ; then
            exit
        else
            nohup python -u HydroWatchSmap.py >> ${appdir}/log/${filename} 2>&1 &
        fi
        sleep 10
    done
